							import java.awt.Canvas;
							import java.awt.Color;
							import java.awt.Graphics;
							import java.awt.Point;
	import java.awt.event.KeyEvent;
	import java.awt.event.KeyListener;
							import java.awt.event.MouseEvent;
							import java.awt.event.MouseListener;
							import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
							
							class MyCanvas extends Canvas implements KeyListener,MouseListener,MouseMotionListener {
								//the enum class that defines the action 
								public enum ACTION{
									DRAG,
									ZOOM,
									ROTATE}
								private boolean clipper=false;
								private static final long serialVersionUID = 1L;
								private int win_Y_max,win_X_max;
								public ArrayList<Vertex> from;
								public ArrayList<Vertex> to;
								public long width,length;
								public int x,y;
								public MyCanvas(long w,long l) {
									width=w;
									length=l;
									x=(int)width/2;
									y=(int)length/2;
									setSize((int)width,(int)length);
									this.
									addMouseListener(this);
									addMouseMotionListener(this);
									addKeyListener(this);
									from = new ArrayList<Vertex>();
									to = new ArrayList<Vertex>();
									//needs to be fix;
									win_Y_max=(int) length;
									win_X_max=(int) width;
								}
								
								Point pStart, pEnd;
								boolean bFlag = false;
								
								public void mouseClicked(MouseEvent arg0) {
									// TODO Auto-generated method stub
							
								}
							
								public void mousePressed(MouseEvent arg0) {
									System.out.println("mouse pressed event");
									// TODO Auto-generated method stub
									ACTION item=null;
									pStart = arg0.getPoint();
									item=define_action (pStart.x,pStart.y);
									System.out.println(item);
									if (item==ACTION.ZOOM){
										zoom();
									}
									if (item==ACTION.DRAG){
										drag();
									}
									if (item==ACTION.ROTATE){
										rotate();
									}
								}
								public void mouseReleased(MouseEvent arg0) {
									// TODO Auto-generated method stub
									pEnd = arg0.getPoint();
									bFlag = true;
									this.repaint();
								}
							
								public void mouseDragged(MouseEvent arg0) {
									// TODO Auto-generated method stub
									pEnd = arg0.getPoint();
									bFlag = true;
									this.repaint();
								}
							
								public void mouseMoved(MouseEvent arg0) {
									// TODO Auto-generated method stub
									
								}
							
								public void mouseEntered(MouseEvent arg0) {
									// TODO Auto-generated method stub
									
								}
							
								public void mouseExited(MouseEvent arg0) {
									// TODO Auto-generated method stub
									
								}
				/************************************************************************************************
				 * 	this function will decide what is the action that is required according the place in the window		
				 */
								//the functions that we use as the functions that will help us inside the listener
								public ACTION define_action (int x, int y ){
									ACTION res = null;
									//if it is in the top 
									if ((y>=0)&&(y<=(win_Y_max/3))){
										if ((x>=0)&&(x<win_X_max/3))
											res=ACTION.ROTATE;
										else if ((x>=win_X_max/3)&&(x<2*win_X_max/3))
											res=ACTION.ZOOM;
										else if ((x>=2*win_X_max/3)&&(x<=win_X_max))
											res=ACTION.ROTATE;
									
									}
									//if it is in the middle
									 if ((y>(win_Y_max/3))&&(y<=(2*win_Y_max/3))){
											if ((x>=0)&&(x<win_X_max/3))
												res=ACTION.ZOOM;
											else if ((x>=win_X_max/3)&&(x<2*win_X_max/3))
												res=ACTION.DRAG;
											else if ((x>=2*win_X_max/3)&&(x<=win_X_max))
												res=ACTION.ZOOM;
									}
									 //if it is in the lowest point
									 if ((y>(2*win_Y_max/3))&&(y<=win_Y_max)){
											if ((x>=0)&&(x<win_X_max/3))
												res=ACTION.ROTATE;
											else if ((x>=win_X_max/3)&&(x<2*win_X_max/3))
												res=ACTION.ZOOM;
											else if ((x>=2*win_X_max/3)&&(x<=win_X_max))
												res=ACTION.ROTATE;
									}
									 //return the place and the required action 
									 return res;
								}
			//create the basic scene that we are working on 	
								public void calc_scene(Scene s) {	
									int n = s.edges.size();
									int v1,v2;
									Vertex p1,p2;
									for (int i=0; i<n; i++){
										v1 = s.edges.get(i).get_p1();
										v2 = s.edges.get(i).get_p2();
										p1 = s.points.get(v1);
										p2=s.points.get(v2);
										from.add(p1);
										to.add(p2);
									}
									
								}
			//paint the scene that we are working on 
								public void paint(Graphics g) {
									
									int n = from.size();
									g.setColor(Color.blue);
									for (int i=0; i<n; i++){
										g.drawLine(from.get(i).get_x()+x,from.get(i).get_y()+y,to.get(i).get_x()+x,to.get(i).get_y()+y);
									}	
								}
							
	public void zoom(){
		System.out.println("zoom 1");
	}
	public void rotate(){
		System.out.println("rotate 1");	
		}
	public void drag(){
		System.out.println("drag 1");
	}

	@Override
	public void keyPressed(KeyEvent e) {
		// TODO Auto-generated method stub
		char typed = e.getKeyChar();
		//make the clipping option available
		if ((typed=='C')||(typed=='c')){
			System.out.println("clipping option");
			clipper=true;
			System.out.println(clipper);
		}
		//reconstruct the original shape
		else if ((typed=='R')||(typed=='r'))
		{
			System.out.println("reconstruct the original shape");
		}
		//get out of the system 
		else if ((typed=='Q')||(typed=='q')){
			System.out.println("exiting the system");
			System.exit(0);
		}
		else{
			System.out.println("ERROR not legal type!!!");
		}
	}

	@Override
	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyTyped(KeyEvent e) {
		// TODO Auto-generated method stub
	}
	}				